package com.app.shop.util.weixinservice;

import com.app.shop.constants.Constants;

import javax.servlet.http.HttpServletRequest;




/**
 * @Title
 * @Description (微信签名参数)
 * @author Garfield Miao
 * @date 2019年21月46日
 * @upAuthor Garfield Miao
 * @update 2019年21月46日
 */
public class SignatParams
{
    private String signature;// 微信加密签名
    private String timestamp;// 时间戳
    private String nonce;// 随机数
    private String echostr;// 随机字符串

    private SignatParams(String signature, String timestamp, String nonce, String echostr)
    {
        this.signature = signature;
        this.timestamp = timestamp;
        this.nonce = nonce;
        this.echostr = echostr;
    }

    public static SignatParams buildParams(HttpServletRequest req)
    {
        String signature = RequestUtil.getStringParameter(req, Constants.SIGNATURE, "");
        String timestamp = RequestUtil.getStringParameter(req, Constants.TIMESTAMP, "");
        String nonce = RequestUtil.getStringParameter(req, Constants.NONCE, "");
        String echostr = RequestUtil.getStringParameter(req, Constants.ECHOSTR, "");

        SignatParams params = new SignatParams(signature, timestamp, nonce, echostr);

        return params;
    }

    public String getSignature()
    {
        return signature;
    }

    public void setSignature(String signature)
    {
        this.signature = signature;
    }

    public String getTimestamp()
    {
        return timestamp;
    }

    public void setTimestamp(String timestamp)
    {
        this.timestamp = timestamp;
    }

    public String getNonce()
    {
        return nonce;
    }

    public void setNonce(String nonce)
    {
        this.nonce = nonce;
    }

    public String getEchostr()
    {
        return echostr;
    }

    public void setEchostr(String echostr)
    {
        this.echostr = echostr;
    }

    @Override
    public String toString()
    {
        return "Params [signature=" + signature + ", timestamp=" + timestamp + ", nonce=" + nonce + ", echostr="
                + echostr + "]";
    }
}
